﻿using System;
using System.Collections.Generic;
using System.Data;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{

    public class VK2WSData : BaseFunction
    {


        public VK2WSData()
            : base()
        {

        }

        public VK2WSData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
        } 
        public DataSet BuildData()
        {
            DataSet setReturn = new DataSet();
            DataSet dsResult = new DataSet();
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT VKPART, "
                    + " TRUNC(SUM(DECODE(TRIM(VKPMEEH),'M',VKPOFFEN/0.9144,VKPOFFEN)/100)) AS QUANTITY "
                    + " FROM VKPOS WHERE VKPSA <> 'AJ' "
                    + " GROUP BY VKPART HAVING SUM(DECODE(TRIM(VKPMEEH),'M',VKPOFFEN/0.9144,VKPOFFEN)/100) >10000 "
                                ;
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "VKPOS";
                }
                setReturn.Merge(dsResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
    }
}